package org.alex.samples.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.constraints.Length;

@Entity
@Table(name = "exam_user")
public class User implements Serializable{
	private static final long serialVersionUID = -3877941525495417139L;
	
	//@NotNull(message = "ID不可以为空！")
	@Id
	@Column(name="user_id",nullable = false)
	private  String id;
	
	//@NotEmpty(message = "姓名不可以为空！")
	@Length(max=15, message="长度不能超过15个字符")
	@Column(name = "user_name",length = 45, nullable = false)
	private  String name;
	
	
	@Column(name = "psw",length = 255, nullable = true)
	private String psw;
	
//    @NotNull(message = "年龄不可以为空！")
//    @Range(min=1,max = 250,message = "只能在1-250之间")
//	private Integer age;
	
	@Column(name = "gender",length = 11, nullable = false)
	private  Integer gender;
	
	@Column(name = "birthday", nullable = false)
	private  String birthday;
	
	@Column(name = "tel",length = 20, nullable = true)
	private  String tel;
	
	@Column(name = "address",length = 255, nullable = true)
	private  String address;
	
	@Column(name = "last_lock_time", nullable = true)
	private Date lastLockTime;
	
	@Column(name = "login_fail_count", nullable = true)
    private Integer loginFailCount;
	
	@OneToMany(mappedBy="user")
	private Set<ExamUserSub> examUserSub;
	
	@OneToMany(mappedBy="examUser",fetch = FetchType.EAGER)
	private Set<ExamUserRole> examUserRole;
	
	
	public Set<ExamUserRole> getExamUserRole() {
		return examUserRole;
	}
	public void setExamUserRole(Set<ExamUserRole> examUserRole) {
		this.examUserRole = examUserRole;
	}
	public String getPsw() {
		return psw;
	}
	public void setPsw(String psw) {
		this.psw = psw;
	}
	public Set<ExamUserSub> getExamUserSub() {
		return examUserSub;
	}
	public void setExamUserSub(Set<ExamUserSub> examUserSub) {
		this.examUserSub = examUserSub;
	}
	public User(){
		super();
	}
	public User(String id, String name,Integer gender,String birthday ,String tel,String address,String psw,Date lastLockTime,Integer loginFailCount) {
		super(); 
		this.id=id;
		this.name=name;
		this.gender=gender;
		this.birthday=birthday;
		this.tel=tel;
		this.address=address;
		this.psw=psw;
		this.lastLockTime=lastLockTime;
		this.loginFailCount=loginFailCount;
	}
	public Date getLastLockTime() {
		return lastLockTime;
	}
	public void setLastLockTime(Date lastLockTime) {
		this.lastLockTime = lastLockTime;
	}
	public Integer getLoginFailCount() {
		return loginFailCount;
	}
	public void setLoginFailCount(Integer loginFailCount) {
		this.loginFailCount = loginFailCount;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getGender() {
		return gender;
	}
	public void setGender(Integer gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	

}


// @Pattern(regexp="^[1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|250$", message="只能是整数且范围在1-250")